#ifndef JAKAROBOTDEVICE_H
#define JAKAROBOTDEVICE_H

#include <QObject>
#include "device.h"
#include "JAKAZuRobot.h"
#include <QJsonObject>

class JakaRobotDevice : public Device
{
    Q_OBJECT
public:
    explicit JakaRobotDevice(QObject *parent = nullptr);

    QString strIP() const;
    void setStrIP(const QString &newStrIP);
    int nPort() const;
    void setNPort(int newNPort);

private:
    JAKAZuRobot         m_robot;
    JointValue          m_joint_pos;

    QString m_strIP;
    int m_nPort;

    bool isInPos(JointValue dest_pos,JointValue cur_pos,double theshold);

signals:
    void strIPChanged();
    void nPortChanged();

public:
    virtual void writeXML(QXmlStreamWriter &writer) override;
    virtual void readFromXML(QXmlStreamReader &reader) override;

    virtual int initDevice() override;
    virtual void writeData(const QVariant &data) override;
    virtual void uninitDevice() override;

    virtual QString getClassName() override;

public:
    Q_PROPERTY(QString strIP READ strIP WRITE setStrIP NOTIFY strIPChanged FINAL)
    Q_PROPERTY(int nPort READ nPort WRITE setNPort NOTIFY nPortChanged FINAL)

};

#endif // JAKAROBOTDEVICE_H
